package com.zhaotianhao.check.userserver.controller;


import com.zhaotianhao.check.userserver.common.JsonResult;
import com.zhaotianhao.check.userserver.entity.City;
import com.zhaotianhao.check.userserver.service.ICityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author Z-7
 * @since 2022-04-01
 */
@RestController
@RequestMapping("/city")
public class CityController {
    @Autowired
    private ICityService iCityService;
    @GetMapping("cities")
    public List<City> getCities(){
        return iCityService.selectAll(1);
    }

    @GetMapping("getCityTree")
    public JsonResult getCityTree(@RequestParam(defaultValue = "1")Integer pid) {
        List<City> cityList =  iCityService.getCityTree(pid);
        return JsonResult.successd(cityList);
    }
}
